﻿<%@ WebHandler Language="C#" Class="ZSTaskOrderManagementHandler" %>

using System;
using System.Web;
using BusinessRule.DTO;
using System.Web.SessionState;
using DatabaseAccess.DBUtility;
using System.Data.OracleClient;
using System.Data;
using System.Linq;
using System.Collections.Generic;
using System.Collections;
using Newtonsoft.Json;
using BusinessRule.Business;
using BusinessRule.IBusiness;
using BusinessRule.BusinessFactory;
using System.IO;
using NPOI.SS.UserModel;
using DatabaseAccess.DBUtility;

public class ZSTaskOrderManagementHandler :IHttpHandler, IRequiresSessionState {
    CurrentUserInfo m_UserInfo;
    private uLMSIssueERPMaterialIbusiness m_issueData = uMESBusinessFactory.instance.GetuLMSIssueERPMaterialObject();
    private uLMSContainerIBusiness m_ContainerObj = uMESBusinessFactory.instance.GetuLMSContainerObject();
    private uLMSCommonIBusiness m_CommonObj = uMESBusinessFactory.instance.GetuLMSCommonObject();
    private SealAndIssueBusiness m_seal = new SealAndIssueBusiness();
    public void ProcessRequest(HttpContext context)
    {
        try
        {
            var action = context.Request["action"].ToString();
            m_UserInfo = (CurrentUserInfo)context.Session["CurrentUserInfo"];
            switch (action)
            {
                case "GetTaskOrderData": //查询任务单信息
                    GetTaskOrderData(context);
                    break;
                case"GetWorkFlowData":
                    GetWorkFlowData(context);
                    break;   
                case"GetBigSmallData":
                    GetBigSmallData(context);
                    break;
                case"CreateTaskOrder":
                    CreateTaskOrder(context);
                    break;  
                case"IssueERPMaterialPopupForm":
                    IssueERPMaterialPopupForm(context);
                    break; 
                case"IssueMaterialAdjustPopupForm":
                    IssueMaterialAdjustPopupForm(context);
                    break;  
                case"PrintData":
                    PrintData(context);
                    break;
                default:
                    break;
            }
        }
        catch (Exception ex)
        {
            var result = new uMESProcessResult();
            result.Result = false;
            result.Message = ex.Message;
            context.Response.ContentType = "text/html";
            context.Response.Write(JsonConvert.SerializeObject(result));
        }
    }
 
    public bool IsReusable {
        get {
            return false;
        }
    }
    /// <summary>
    /// 查询任务单信息
    /// </summary>
    /// <param name="context"></param>
    private void GetTaskOrderData(HttpContext context) 
    {
        var argPara=JsonConvert.DeserializeObject<Dictionary<string,string>>(context.Request["data"].ToString());
        string pageSize = context.Request["pageSize"].ToString();
        string pageNumber = context.Request["pageNumber"].ToString();
        var para = new Dictionary<string, string>();
        para.Add("CurrentPageIndex", pageNumber);
        para.Add("PageSize", pageSize);
        para.Add("TaskBill", argPara["TaskBill"]);
        para.Add("MfgOrder", argPara["MfgOrdername"]);
        para.Add("MachineStart", argPara["Machine"]);
        if (!argPara["Status"].Equals("全部")) { para.Add("Status", argPara["Status"]); }
        para.Add("HasBom", argPara["HasBom"]);
        para.Add("FactoryId", m_UserInfo.FactoryID);
            
        uMESProcessResult result = m_issueData.GetIssueERPMaterial(para);
        context.Response.Write(JsonConvert.SerializeObject(result));
    }
    /// <summary>
    /// 查询工艺信息
    /// </summary>
    /// <param name="context"></param>
    private void GetWorkFlowData(HttpContext context) 
    {
        var workFlowid = context.Request["workflowid"].ToString();
        uMESProcessResult result = new uMESProcessResult();
        result.DBTable=m_seal.GetWorkFlowData(workFlowid);
        result.Result = result.DBTable.Rows.Count > 0;
        context.Response.Write(JsonConvert.SerializeObject(result));
    }
    /// <summary>
    /// 查询大小件信息
    /// </summary>
    /// <param name="context"></param>
    private void GetBigSmallData(HttpContext context) 
    {
        var specid = context.Request["workflowstepid"].ToString();
        var argPara = JsonConvert.DeserializeObject<Dictionary<string, string>>(context.Request["data"].ToString());
        var para = new Dictionary<string,string>();
        para.Add("WorkflowId", argPara["WORKFLOWID"]);
        para.Add("ContainerNo", argPara["CONTAINERNO"]);
        para.Add("ContainerId", argPara["CONTAINERID"]);
        para.Add("PartType", "0");
        para.Add("specid", specid);
        para.Add("mfgorderId", argPara["MFGORDERID"]);
        DataTable  dtBig = m_issueData.GetIssueMenuInfoDS(para).Tables["dtIssueSum"];
        para["PartType"] = "1";
        DataTable  dtSmall = m_issueData.GetIssueMenuInfoDS(para).Tables["dtIssueSum"];
        if(dtBig.Rows.Count + dtSmall.Rows.Count == 0){//未生成,获取bom零件信息
            var paraBom=new Dictionary<string,string>();
            paraBom.Add("specid", specid);
            paraBom.Add("BomId", argPara["BOMID"]);
            paraBom.Add("FirstSecondIssue", m_ContainerObj.CheckFirstSecondIssueNew(argPara["CONTAINERID"]));
            paraBom.Add("EngineProduct", m_issueData.GetEngineProduct(argPara["MFGORDERNAME"]));
            DataTable dtBom = m_issueData.CalcBomData(paraBom);
             DataView dv= dtBom.DefaultView;
             if( dtBom.Rows.Count > 0) {
                    dv.RowFilter = "Bigsmallpart='大零件'";
                    dtBig = dv.ToTable();

                    dv = dtBom.DefaultView;
                    dv.RowFilter = "Bigsmallpart='小零件'";
                    dtSmall = dv.ToTable();
             }
        }
        uMESProcessResult result = new uMESProcessResult();
        result.DBTable = dtBig;
        result.ReturnData = dtSmall;
        result.Result = result.DBTable.Rows.Count > 0;
        context.Response.Write(JsonConvert.SerializeObject(result));
    }

    private void IssueERPMaterialPopupForm(HttpContext context)
    {
        uMESProcessResult result = new uMESProcessResult();
        var argPara = JsonConvert.DeserializeObject<Dictionary<string, string>>(context.Request["data"].ToString());
        var para=new Dictionary<string,string>();
        para.Add("BomId", argPara["BOMID"]);
        para.Add("ContainerNo", argPara["CONTAINERNO"]);
        para.Add("MfgOrderName", argPara["MFGORDERNAME"]);
        DataTable dt = m_CommonObj.GetContainerInfobyContainerName(argPara["CONTAINERNAME"]);
        if (dt.Rows.Count==0) {
            result.Message = "批次ID异常!";
        }
        para.Add("ContainerId",dt.Rows[0]["Containerid"].ToString());
        para.Add("EngineProduct", m_issueData.GetEngineProduct(argPara["MFGORDERNAME"]));
        para.Add("WorkFlowId",argPara["WORKFLOWID"]);
        context.Session["PopupAdjust"] = para;
        result.Result = true;
        context.Response.Write(JsonConvert.SerializeObject(result));
    }
    private void IssueMaterialAdjustPopupForm(HttpContext context)
    {
        uMESProcessResult result = new uMESProcessResult();
        context.Session["ContainerNoAdjust"] = context.Request["data"].ToString();
        result.Result = true;
        context.Response.Write(JsonConvert.SerializeObject(result));
    }
    private void PrintData(HttpContext context) 
    {
        uMESProcessResult result = new uMESProcessResult();
        DataTable argdt = JsonConvert.DeserializeObject<DataTable>(context.Request["data"].ToString());
        var type = context.Request["type"].ToString();
        DataTable dt = new DataTable();
        if (type.Equals("all") || type.Equals("allbig") || type.Equals("allsmall")) 
        {
            if (string.IsNullOrWhiteSpace(argdt.Rows[0]["attributevalue"].ToString())) {
                result.Message = "发动机号为空";
                context.Response.Write(JsonConvert.SerializeObject(result));
                return;
            }
            dt = m_issueData.GetContainerNoByMachine(argdt.Rows[0]["attributevalue"].ToString());
            if (dt.Rows.Count==0)
            {
                result.Message = "没有整机资料，请确定是否生成任务单";
                context.Response.Write(JsonConvert.SerializeObject(result));
                return;
            }
            context.Session["DT"] = dt;
            result.Result = true;
            context.Response.Write(JsonConvert.SerializeObject(result));
            return;  
        }
         dt.Columns.Add("ContainerID");
         dt.Columns.Add("attributevalue");
         dt.Columns.Add("description");
         dt.Columns.Add("productname");
         dt.Columns.Add("ContainerNo");
         foreach(DataRow row in argdt.Rows)
         {
            var  ContaienrID=row["ContainerID"].ToString();
            var attributevalue = string.IsNullOrWhiteSpace(row["attributevalue"].ToString()) ? "" : row["attributevalue"].ToString();
            var description = string.IsNullOrWhiteSpace(row["description"].ToString()) ? "" : row["description"].ToString();
            var  productname= string.IsNullOrWhiteSpace(row["productname"].ToString())?"":row["productname"].ToString();
            var  ContainerNo= string.IsNullOrWhiteSpace(row["ContainerNo"].ToString())?"":row["ContainerNo"].ToString();
            dt.Rows.Add(ContaienrID, attributevalue, description, productname, ContainerNo);
         }
        dt.AcceptChanges();
        context.Session["DT"] = dt;
        result.Result = true;
        context.Response.Write(JsonConvert.SerializeObject(result));
    }
    
    
    /// <summary>
    /// 生成任务单
    /// </summary>
    /// <param name="context"></param>
    private void CreateTaskOrder(HttpContext context) 
    {
        var dt = JsonConvert.DeserializeObject<DataTable>(context.Request["data"].ToString());
        var mfgStock=new Dictionary<string,int>();
        uMESProcessResult result = new uMESProcessResult();
        var msg = string.Empty;
         //1.开卡 2.生成大小件目录 3.自动配套
        foreach(DataRow row in dt.Rows){
            var conditionPara=new Dictionary<string,string>();
            conditionPara.Add("containername", "'"+row["containername"].ToString()+"'");
            DataTable dtt = m_CommonObj.GetTableInfoByField("enginepartplan", conditionPara, null);//表---enginepartplan
            if (dtt.Rows.Count>1) {
                result.Message = "批次生成异常!,存在重复批次，请联系管理员";
                context.Response.Write(JsonConvert.SerializeObject(result));
                return;
            }
           
            //a.StartContainersByMfgId---------------
            DataTable mfgcDT = m_issueData.GetMfgContainerDT(row["MfgorderId"].ToString(), row["containerno"].ToString());//---uLMSIssueERPMaterialBusiness.vb---856---
            foreach (DataRow mfgrow in mfgcDT.Rows) 
            {
                //新增开批次功能
                var Sresult = StarContainer(mfgrow);
                if (Sresult.IsError)
                {
                    result.Message = Sresult.Message;
                    context.Response.Write(JsonConvert.SerializeObject(result));
                    return;
                }
            }

            DataTable dtExcept = m_issueData.GetTaskExceptionData(row["MfgorderId"].ToString());//----uLMSIssueERPMaterialBusiness----34---------
            if (dtExcept.Rows.Count > 0) 
            {
                var SQLTransList = new List<object[]>();
                foreach (DataRow drE in dtExcept.Rows) 
                {
                    //'判断如果为相同订单，相同批次号------926------
                    SQLTransList.Add(m_issueData.FillUpdateEnginePartPlanID(drE["containerid"].ToString(), drE["ContainerName"].ToString(), drE["productid"].Equals(drE["mproductid"]) && !string.IsNullOrWhiteSpace(row["workflowstepname"].ToString())));
                }
                if (SQLTransList.Count > 0) 
                {
                    DatabaseHelper.ExecuteSqlTran(SQLTransList);
                }
            }

            dtt = m_CommonObj.GetContainerInfobyContainerName(row["ContainerName"].ToString());//-----uLMSCommonBusiness.vb---1199---
            if (dt.Rows.Count == 0) {
                result.Message = "批次生成异常!,请重新生成任务单";
                context.Response.Write(JsonConvert.SerializeObject(result));
                return;
            }
            //如果是没有大小件目录，只开卡，不生成大小件目录、不自动配套
            if (context.Request["HasBom"].ToString().Equals("无"))
            {
                result.Message = "生成成功";
                result.Result = true;
                continue;
            }
            //b.生成大小件目录------------------------
            //根据选择的记录判断零件目录是否生成，没有则生产零件目录
            var para=new Dictionary<string,string>();
                para.Add("EmployeeId",m_UserInfo.EmployeeID);
                para.Add("BomId",row["BomId"].ToString()); 
                para.Add("ContainerNo",row["togetherflag"].ToString());
                para.Add("MfgOrderName", row["MfgOrderName"].ToString());
                para.Add("ContainerId", dtt.Rows[0]["Containerid"].ToString());
                para.Add("WorkFlowId",row["WorkflowId"].ToString());
            //一个任务单不同大阶段只配套一个批次
                DataTable dtIssue = m_issueData.GetIssueErpMaterialbyCid(para["ContainerId"]);//---uLMSIssueERPMaterialBusiness----966------
             if (dtIssue.Rows.Count == 0) {
                 dtIssue = m_issueData.GetIssueErpMaterialbyCno(para["ContainerNo"]);//---uLMSIssueERPMaterialBusiness----987------
                 if (dtIssue.Rows.Count > 0) {
                     result.Message = "生成成功";
                     result.Result = true;
                     continue;
                 }
             }
            
              para.Add("FirstSecondIssue",m_ContainerObj.CheckFirstSecondIssueNew(para["ContainerId"]));//判断出装、检装
              para.Add("EngineProduct", row["mproductname"].ToString());
              if (!GeneratePartMenu(para)) {
                  if (!msg.Contains("没有生成零件目录"))
                  {
                    msg+="没有生成零件目录";
                  }
                  continue;
              }
              //c.-自动配套任务单-----------------------------
              if (mfgStock.ContainsKey(para["MfgOrderName"])) {
                  if (mfgStock["MfgOrderName"] == 0) { continue; }
              } else {
                  //C1--判断订单是否有从ERP需要配套的库存
                  para["OnlyStock"] = "1";
                  DataSet ds = m_issueData.GetCollectStockQty(para);//---uLMSIssueERPMaterialBusiness---592--获取ERP订单配套大小件信息
                  DataTable dtStock = ds.Tables["Stock"];
                  mfgStock.Add("MfgOrderName", dtStock.Rows.Count);
                  if (dtStock.Rows.Count == 0) {
                      //result.Message = "没有配套件";
                      if (!msg.Contains("没有配套件"))
                      {
                          msg += "没有配套件";
                      }
                      continue;
                  }
              }
              
            var paraSp=new Dictionary<string,string>();
                paraSp.Add("V_MFGORDER",para["MfgOrderName"]);
                paraSp.Add("V_CONTAINERNO",para["ContainerNo"]);
                paraSp.Add("V_CONTAINERID",para["ContainerId"]);
                paraSp.Add("V_EMPLOYEEID",para["EmployeeId"]);
                paraSp.Add("WorkFlowId", para["WorkFlowId"]);
                //AutoMatchTaskBill_SP(paraSp)
                //C2--'判断有没配齐
                DataTable dtIssuee = m_issueData.GetIssueMaterialNotFinished(paraSp);//------uLMSIssueERPMaterialBusiness-------2140-------
                if (dtIssuee.Rows.Count==0) {//已配齐，循环下一个任务单
                    continue;
                }
                //C3--'判断物料库存，有库存
                DataTable dtErpBuffer = m_issueData.GetCollectErpBufferData(paraSp);//-----uLMSIssueERPMaterialBusiness--------2166-------
                if (dtErpBuffer.Rows.Count == 0)//没有需要配套的物料(没有库存)
                {
                    continue;
                }
                var strProductList = string.Empty;
                foreach (DataRow drIssue in dtIssuee.DefaultView.ToTable(true, "productname").Rows)
                {
                    strProductList += drIssue["productname"].ToString() + ",";
                }
                strProductList = strProductList.Substring(0, strProductList.Length - 1);
                DataTable dtBufferData = dtErpBuffer.Clone();
                DataRow[] tempRows = dtErpBuffer.Select(String.Format(" productname in ('{0}')", strProductList.Replace(",", "','")));
                if (tempRows.Length > 0) { dtBufferData = tempRows.CopyToDataTable(); }
                if (dtBufferData.Rows.Count == 0)//没有需要配套的物料
                {
                    msg += "没有需要配套的物料,";
                    continue;
                }

                var issueqty = 0;
                var ASQLTransList=new List<object[]>();
                foreach (DataRow drissue in dtIssuee.Rows)
                {
                    var skipqty = Convert.ToInt32(drissue["skipqty"].ToString()); //'缺的数量     
                    foreach (DataRow drbuffer in dtBufferData.Rows) {
                        if (!drissue["productname"].ToString().Equals(drbuffer["productname"].ToString())) { continue; }
                        if (skipqty <= 0) { continue; }
                        var stockqty = Convert.ToInt32(drbuffer["stockqty"].ToString()); //库存可用数量     
                        if (skipqty <= stockqty) { issueqty = skipqty; } else { issueqty = stockqty; }
                        skipqty = skipqty - issueqty;
                        var entity = new IssueERPMaterialDTO();
                        entity.CollectERPMaterialID = drbuffer["Collecterpmaterialid"].ToString();
                        entity.ContainerNo = paraSp["V_CONTAINERNO"];
                        entity.ContainerID = paraSp["V_CONTAINERID"];
                        entity.EmployeeId = m_UserInfo.EmployeeID;
                        entity.FactoryID = m_UserInfo.FactoryID;
                        entity.IssueQty = issueqty.ToString();
                        entity.PartMenuInfoID = drissue["partmenuinfoid"].ToString();
                        entity.IssueERPMaterialID = Guid.NewGuid().ToString();
                        entity.BommateriallistitemID = "";
                        entity.Note = "";
                        entity.ToIssueERPMaterialID = "";
                        entity.AssembleTimes = "";
                        entity.ProductChildNO = "";
                        entity.WorkflowStepID = string.IsNullOrWhiteSpace(drissue["workflowstepid"].ToString()) ? "" : drissue["workflowstepid"].ToString();
                        ASQLTransList.Add(m_issueData.FillInsertIssueErpMaterial(entity));//-----uLMSIssueERPMaterialBusiness---681---
                    }
                }
                if (ASQLTransList.Count > 0) {
                  result.Result= DatabaseHelper.ExecuteSqlTran(ASQLTransList);
                }
        }
        result.Message = result.Result ? "生成成功:" + msg.TrimEnd(',') : "生成失败:" + msg.TrimEnd(',');
        context.Response.Write(JsonConvert.SerializeObject(result));
    }
    /// <summary>
    ///  开卡--生成任务单信息
    /// </summary>
    /// <param name="dr"></param>
    /// <returns></returns>
    private Camstar.WebClient.WebServicesProxy.InSiteWebServices.ResultStatus StarContainer(DataRow dr)
    {
            var containerBaseInfo= new ContainerStartInfo();
            containerBaseInfo.ContainerName = dr["ContainerName"].ToString();
            containerBaseInfo.Qty = 1;
            containerBaseInfo.MfgOrder = dr["MfgOrderName"].ToString();
            containerBaseInfo.IsSelfMfg = 0;
            //FillContainerDefaultInfo(containerBaseInfo);
            containerBaseInfo.TogetherFlag = dr["TogetherFlag"].ToString();
            containerBaseInfo.Factory = m_UserInfo.Factory;
            containerBaseInfo.StartEmployee = m_UserInfo.EmployeeName;
            containerBaseInfo.ProductName = dr["ProductName"].ToString();
            containerBaseInfo.ProductRevision = dr["ProductRevision"].ToString();
            containerBaseInfo.ProductuseROR = false;
            containerBaseInfo.MfgWorkflowName = dr["WorkflowName"].ToString();
            containerBaseInfo.MfgWorkflowRevision = dr["WorkflowRevision"].ToString();
            containerBaseInfo.MfgWorkflowuseROR = false;
            containerBaseInfo.WorkflowName = dr["WorkflowName"].ToString();
            containerBaseInfo.WorkflowRevision = dr["WorkflowRevision"].ToString();
            containerBaseInfo.WorkflowuseROR = false;
            containerBaseInfo.PlannedStartDate = DateTime.Parse(dr["PlannedStartDate"].ToString()).ToString("yyyy-MM-ddTHH:mm:ss");
            containerBaseInfo.PlannedCompletionDate = DateTime.Parse(dr["PlannedFinishDate"].ToString()).ToString("yyyy-MM-ddTHH:mm:ss");
            containerBaseInfo.ContainerType = 7;
            containerBaseInfo.AttributeList = new DataTable();
            //填充批次默认信息
            var strOwner = string.Empty;
            var strLevel = string.Empty;
            var strStart = string.Empty;
            DataTable levelAttributes = m_CommonObj.GetFatoryAttributes(m_UserInfo.FactoryID);
            DataRow[] datarows = levelAttributes.Select("USERATTRIBUTENAME='默认所有者'");
            if (datarows.Length > 0) { strOwner = datarows[0]["ATTRIBUTEVALUE"].ToString(); }
            datarows = levelAttributes.Select("USERATTRIBUTENAME='默认层级'");
            if (datarows.Length > 0) { strLevel = datarows[0]["ATTRIBUTEVALUE"].ToString(); }
            if (string.IsNullOrWhiteSpace(containerBaseInfo.MfgOrder.ToString()))
            {
                datarows = levelAttributes.Select("USERATTRIBUTENAME='无订单开始原因'");
            }
            else {
                datarows = levelAttributes.Select("USERATTRIBUTENAME='订单开始原因'");
            }
            if (datarows.Length > 0) { strStart = datarows[0]["ATTRIBUTEVALUE"].ToString(); }
            containerBaseInfo.StartReason = strStart;
            containerBaseInfo.Level = strLevel;
            containerBaseInfo.Owner = strOwner;
             var serverInfo=new ServerHostInfo();//Carmstar API调用 用户密码
            serverInfo.UserName = m_UserInfo.APIUserName;
            serverInfo.Password = m_UserInfo.APIPassword;
            containerBaseInfo.ServerHostInfo = serverInfo;
            return m_ContainerObj.StartContainer(containerBaseInfo);//-----uLMSContainerBusiness-----26---
    }
    
    /// <summary>
    /// 自动生成零件目录
    /// </summary>
    /// <param name="para"></param>
    /// <returns></returns>
    private bool GeneratePartMenu(Dictionary<string,string> para) 
    {
        var result=false;
        var SQLTransList=new List<object[]>();
        DataTable PartmenuDt= m_issueData.GetPartMenuinfo(para);//获取零件目录信息---------432---------
        var m_IsERPMaterialDTO = new IssueERPMaterialDTO();
        var dt = m_issueData.CalcBomDatabyWorkflowid(para);//获取工艺下的零件信息-------363-------
        foreach(DataRow dr in dt.Rows)
        {
            m_IsERPMaterialDTO.ProductID = dr["productid"].ToString();
            m_IsERPMaterialDTO.OriginalProductID = dr["productid"].ToString();
            m_IsERPMaterialDTO.FirstAssembleQty = dr["OriginalFirstAssembleQty"].ToString();
            m_IsERPMaterialDTO.OriginalFirstAssembleQty = dr["OriginalFirstAssembleQty"].ToString();
            m_IsERPMaterialDTO.CheckAssembleQty = dr["OriginalCheckAssembleQty"].ToString();
            m_IsERPMaterialDTO.OriginalCheckAssembleQty = dr["OriginalCheckAssembleQty"].ToString();
            m_IsERPMaterialDTO.PartMenuInfoID = System.Guid.NewGuid().ToString();
            m_IsERPMaterialDTO.ContainerNo = para["ContainerNo"];
            m_IsERPMaterialDTO.Reason = "";
            m_IsERPMaterialDTO.PartType = dr["PartType"].ToString();
            m_IsERPMaterialDTO.Effectiveness = "1";
            m_IsERPMaterialDTO.EmployeeId = m_UserInfo.EmployeeID;
            m_IsERPMaterialDTO.SpecId = dr["specid"].ToString();
            m_IsERPMaterialDTO.Note = dr["notes"].ToString().Equals("1") ? "必换件" : string.Empty; 
            if(PartmenuDt.Rows.Count > 0){
                //originalproductid--原零件ID  CONTAINERNO---流水卡NO
                 DataRow[] rows= PartmenuDt.Select("originalproductid='" + dr["productid"].ToString() + "' AND specid='" +dr["specid"].ToString() +"'");
                if(rows.Length == 0){
                    rows = PartmenuDt.Select("originalproductid='" + dr["productid"].ToString() + "' AND CONTAINERNO='" + para["ContainerNo"] + "'");
                }
                if (rows.Length > 0) {
                    m_IsERPMaterialDTO.PartMenuInfoID = rows[0]["partmenuinfoid"].ToString();
                    m_issueData.DeletePartMenuInfo(m_IsERPMaterialDTO);//已生成，则先删除，再新建 ID不变-------567-------
                }
            }
            SQLTransList.Add(m_issueData.FillInsertPartMenu(m_IsERPMaterialDTO));//--------498---------
        }
        if (SQLTransList.Count>0) {
            result = DatabaseHelper.ExecuteSqlTran(SQLTransList);
        }
        return result;
    }

}